// wjg
// //////////////////////////////////////////////////////////
var photoCtx = new ModuleContext('Photo','照片');

var appui = new ModuleUI(photoCtx);

appui.checkEditForm = function(){
	var vConf = {};
	//
 	vConf = [
	{"name":"id","format":"Integer","tip":" 格式错误!"}
	, {"name":"albumId","format":"Integer","tip":"相册 格式错误!"}
	];
	var v = new Validator(photoCtx.EDIT_FORM_ID, vConf, true);
	var ok = v.validate();
	if(!ok){
		return false;
	}
	return true;
}

appui.setViewItem = function(dataObj, viewObj){
	viewObj.setAttribute('class','row');
	viewObj.setAttribute('id', 'XXXListItem_' + dataObj.id);
	var children = DomUtil.getChildren(viewObj);
	children[0].firstChild.value = dataObj['id'];
	children[1].innerHTML = Widget.getView(dataObj['id'], 'hidden');
	children[2].innerHTML = Widget.getView(dataObj['title'], 'text');
	UploadFileUtil.previewImg(null, dataObj['path'], children[3]);
	children[4].innerHTML = Widget.getView(dataObj['remark'], 'text');
	children[5].innerHTML = Widget.getView(dataObj['albumId'], 'select');
	children[6].innerHTML = Widget.getView(dataObj['created'], 'date');
	children[7].innerHTML = Widget.getView(dataObj['modified'], 'date');
	children[8].firstChild.onclick = function(){appui.editXXX(dataObj.id);};
	children[9].firstChild.onclick = function(){appui.deleteXXX(dataObj.id);};
}

appui.setEditFiles = function(dataObj){
	UploadFileUtil.editFile(dataObj['path'], 'path', $E('PhotoEditForm')['path']);}

EventUtil.addEvent(window, 'load', function(){

		var url_select = URL_ROOT+'/album/select.json';
		ajaxRequest(url_select, null, function(result){
			FormUtil.bindSelectOptions($E('searchForm')['albumId'], result.data, 'id', 'name');
			FormUtil.bindSelectOptions($E('PhotoEditForm')['albumId'], result.data, 'id', 'name');
		});
	
});

//////////////////////////////////////////////////////////